home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Extender Bars (Kashidas).c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.8 KB  |  106 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. static char arabicString[8] = {'\xE5', '\xC7', '\xE3', '\xE6', '\xCA', '\xE8', '\xD4', 0};
  36.  
  37. void ExtenderBars(WindowPtr sampleWindow)
  38.     {
  39.     /* Variables */
  40.     char                                *myString = (char *) &arabicString[0];
  41.     gxLayoutOptions                gxLayoutOptions;
  42.     gxLine                                myLine;
  43.     gxPoint                                myPoint;
  44.     gxRunControls                    gxRunControls;
  45.     gxShape                                layout;
  46.     short                                len, level = 0;
  47.     gxStyle                                myStyle;
  48.     gxViewPort                        aViewPort;
  49.     
  50.     /* Initialization */
  51.     
  52.     myPoint.x = ff(30);
  53.     myPoint.y = ff(50);
  54.     
  55.     aViewPort = GXNewWindowViewPort(sampleWindow);
  56.     SetDefaultViewPort(aViewPort);
  57.     
  58.     len = MyStrLen(myString);
  59.     InitializeRunControls(&gxRunControls);
  60.     
  61.     InitializeLayoutOptions(&gxLayoutOptions);
  62.     gxLayoutOptions.width = ff(500);
  63.     gxLayoutOptions.just = 0;
  64.     
  65.     myLine.first.x = myLine.last.x = myPoint.x;
  66.     myLine.first.y = 0;
  67.     myLine.last.y = ff(1000);
  68.     GXDrawLine(&myLine);
  69.     
  70.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  71.     GXDrawLine(&myLine);
  72.     
  73.     myStyle = NewLayoutStyle((char *) "\pDiwan", ff(50), gxNoMetricsGridText, nil, nil, 0, nil);
  74.     
  75.     layout = GXNewLayout(
  76.         1, &len, (void *) &myString,
  77.         1, &len, &myStyle,
  78.         1, &len, &level,
  79.         &gxLayoutOptions, &myPoint);
  80.     GXDrawShape(layout);
  81.     
  82.     gxLayoutOptions.just = fract1 / 4;
  83.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  84.     GXMoveShape(layout, 0, ff(75));
  85.     GXDrawShape(layout);
  86.     
  87.     gxLayoutOptions.just = fract1 / 2;
  88.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  89.     GXMoveShape(layout, 0, ff(75));
  90.     GXDrawShape(layout);
  91.     
  92.     gxLayoutOptions.just = 3 * (fract1 / 4);
  93.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  94.     GXMoveShape(layout, 0, ff(75));
  95.     GXDrawShape(layout);
  96.     
  97.     gxLayoutOptions.just = fract1;
  98.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  99.     GXMoveShape(layout, 0, ff(75));
  100.     GXDrawShape(layout);
  101.     
  102.     GXDisposeShape(layout);
  103.     GXDisposeStyle(myStyle);
  104.     GXDisposeViewPort(aViewPort);
  105.     }    /* main */
  106.